/**
 * 
 */
package com.neal.utils;

import org.springframework.binding.message.MessageBuilder;
import org.springframework.binding.validation.ValidationContext;

/**
 * @author Neal
 * @version 1.0
 * @description
 */
public class MessageUtils {

	/**
	 * add Message To Web Flow Validation
	 * 
	 * @param validationContext
	 * @param source
	 * @param code
	 * @param defaultText
	 */
	public static void addMessageToValidator(ValidationContext validationContext, Object source, String code,
			String defaultText) {
		validationContext.getMessageContext().addMessage(
				new MessageBuilder().error().source(source).code(code).defaultText(defaultText).build());
	}

	/**
	 * add Message To Web Flow Validation
	 * 
	 * @param validationContext
	 * @param source
	 * @param code
	 * @param params
	 */
	public static void addMessageToValidator(ValidationContext validationContext, Object source, String code,
			Object... args) {
		validationContext.getMessageContext().addMessage(
				new MessageBuilder().error().source(source).code(code).args(args).build());
	}

	/**
	 * add Message To Web Flow Validation
	 * 
	 * @param validationContext
	 * @param source
	 * @param code
	 */
	public static void addMessageToValidator(ValidationContext validationContext, Object source, String code) {
		validationContext.getMessageContext()
				.addMessage(new MessageBuilder().error().source(source).code(code).build());
	}
}
